package jlib.component.animation
{
	import flash.display.DisplayObject;
	
	import jlib.component.animation.Animation;
	
	public class AlphaAnimation extends Animation {
		
		private var m_from:Number;
		private var m_to:Number;
		private var m_bAutoReset:Boolean;
		private var m_bAutoReverse:Boolean;
		
		public function AlphaAnimation($target:DisplayObject, $duration:Number, $from:Number, $to:Number, $easing:Function=null, $yoyo:Boolean=false, $autoReset:Boolean=true, $autoReverse:Boolean=false) {
			super($target, $duration, $easing, $yoyo);
			m_from = $from;
			m_to = $to;
			m_bAutoReset = $autoReset;
			m_bAutoReverse = $autoReverse;
		}
		
		override public function start($param:*=null):void {
			if(i_bRegisted && m_bAutoReverse) reverse();
			regist();
			i_bStop = false;
			if(m_bAutoReset) reset();
		}
		
		override public function move($step:*): void {
			var rate:Number = $step;
			if(i_yoyo) rate = Math.sin(Math.PI*rate);
			if(i_easing != null) rate = i_easing(rate, m_from, m_to, 1);
			i_target.alpha = rate;
		}		
		
	}//c
}